package org.systm.security.init;

import lombok.Getter;
import lombok.Setter;

import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;


@Getter
public enum MappingPermission {
    /** 系统用户 */
    SYSTEM_USER_UPDATE("/admin/user/update", "system:user:update", "修改系统用户"),
    SYSTEM_USER_DEL("/admin/user/del", "system:user:del", "删除系统用户"),
    SYSTEM_USER_INSERT("/admin/user/insert", "system:user:insert", "新增系统用户"),
    SYSTEM_USER_ALL("/admin/user/all", "system:user:all", "查询所有系统用户"),
    /** 系统角色 */
    SYSTEM_ROLE_ALL("/admin/role/all", "system:role:all", "查询所有系统角色"),
    SYSTEM_ROLE_INSERT("/admin/role/insert", "system:role:insert", "新增系统角色"),
    SYSTEM_ROLE_DEL("/admin/role/del", "system:role:del", "删除系统角色"),
    SYSTEM_ROLE_UPDATE("/admin/role/update", "system:role:update", "修改系统角色"),
    /** 系统权限标识 */
    SYSTEM_PERMISSION_ALL("/admin/permission/all", "system:permission:all", "查询所有系统权限标识"),
    SYSTEM_PERMISSION_INSERT("/admin/permission/insert", "system:permission:insert", "新增系统权限标识"),
    SYSTEM_PERMISSION_DEL("/admin/permission/del", "system:role:permission", "删除系统权限标识"),
    SYSTEM_PERMISSION_UPDATE("/admin/permission/update", "system:permission:update", "修改系统权限标识"),
    /** 菜单 */
    SYSTEM_MENU_ALL("/menu/all", "system:menu:all", "查询所有菜单"),
    SYSTEM_MENU_INSERT("/menu/insert", "system:menu:insert", "新增菜单"),
    SYSTEM_MENU_DEL("/menu/del", "system:menu:del", "删除菜单"),
    SYSTEM_MENU_UPDATE("/menu/update", "system:menu:update", "修改菜单");


    private final String url;
    private final String permission;
    private final String spec;
    public static final Map<String, MappingPermission> mappingMap = Arrays.stream(values()).collect(Collectors.toMap(
            MappingPermission::getUrl,
            (mp) -> mp
    ));
    public static final List<MappingPermission> mappingList = Arrays.stream(values()).collect(Collectors.toList());
    MappingPermission(String url, String permission, String spec) {
        this.url = url;
        this.permission = permission;
        this.spec = spec;
    }
}
